﻿using GarminUploader.Connector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GarminUploader
{
    public class FileConnectionDict
    {
        private Dictionary<FitFile, List<ConnectorType>> outstandingFiles;

        public FileConnectionDict()
        {
            outstandingFiles = new Dictionary<FitFile, List<ConnectorType>>();
        }

        public void addConnection(FitFile file, ConnectorType connectorType)
        {
            // First check if there is an entry for filename
            if (outstandingFiles.ContainsKey(file))
            {
                // Add to the existing entry
                outstandingFiles[file].Add(connectorType);
            }
            else
            {
                // Create a new entry
                outstandingFiles.Add(file, new List<ConnectorType> { connectorType });
            }
        }

        public List<FitFile> getFiles()
        {
            return outstandingFiles.Keys.ToList();
        }

        public List<ConnectorType> getConnections(FitFile file)
        {
            // First check if there is an entry for filename
            if (outstandingFiles.ContainsKey(file))
            {
                return outstandingFiles[file];
            }
            else
            {
                // Else return an empty list
                return new List<ConnectorType>();
            }
        }
    }
}